using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {      
            LoadControl();
            ShowFunctions();
            Page.Title = "Karnel Travel";
  
    }
    protected void lnkAllBooking_Click(object sender, EventArgs e)
    {
    }
    protected void LoadControl()
    {
        contentHolder.Controls.Clear();
        string ctrl = Request["ctrl"];
        switch (ctrl)
        {
            case "profile": contentHolder.Controls.Add(Page.LoadControl("Profile.ascx")); lblPageTitle.Text = "Profile"; break;
            case "home": contentHolder.Controls.Add(Page.LoadControl("Home.ascx")); lblPageTitle.Text = "Home"; break;
            case "booking_list": contentHolder.Controls.Add(Page.LoadControl("BookingList.ascx")); lblPageTitle.Text = "Bookings"; break;
            case "booking_det": if (Request["mode"] == "1"){ contentHolder.Controls.Add(LoadControl("PackageBookingManagement.ascx")); lblPageTitle.Text="Package booking details" ; }
                else if (Request["mode"] == "2") { contentHolder.Controls.Add(LoadControl("FacilityBookingManagement.ascx")); lblPageTitle.Text = "Facility booking details"; }
                else if (Request["mode"] == "3") { contentHolder.Controls.Add(LoadControl("CustomBookingManagement.ascx")); lblPageTitle.Text = "Custom booking details"; }
                                break;
                                
            case "tour": contentHolder.Controls.Add(Page.LoadControl("TourManagement.ascx")); lblPageTitle.Text="Tour" ; break;

            case "tour_list": contentHolder.Controls.Add(Page.LoadControl("TourList.ascx"));  lblPageTitle.Text="All tours"; break;

            case "spot": contentHolder.Controls.Add(Page.LoadControl("SpotManagement.ascx")); lblPageTitle.Text="Tour Spot"; break;

            case "spot_list": contentHolder.Controls.Add(Page.LoadControl("SpotList.ascx"));lblPageTitle.Text="All spots" ; break;

            case "spot_cate": contentHolder.Controls.Add(Page.LoadControl("SpotCategoryManagement.ascx")); lblPageTitle.Text="Spot category"; break;
            case "spot_cate_list": contentHolder.Controls.Add(Page.LoadControl("SpotCategoryList.ascx")); lblPageTitle.Text = "All spot category"; break;
            case "place": contentHolder.Controls.Add(Page.LoadControl("PlaceManagement.ascx"));lblPageTitle.Text="Place" ; break;

            case "place_list": contentHolder.Controls.Add(Page.LoadControl("PlaceList.ascx")); lblPageTitle.Text="All places"; break;

            case "place_cate": contentHolder.Controls.Add(Page.LoadControl("PlaceCategoryManagement.ascx"));lblPageTitle.Text="Place category" ; break;
            case "loc": contentHolder.Controls.Add(Page.LoadControl("LocationManagement.ascx")); lblPageTitle.Text = "Location Details"; break;
            case "loc_list": contentHolder.Controls.Add(Page.LoadControl("LocationList.ascx")); lblPageTitle.Text = "Locations"; break;
            case "facility": contentHolder.Controls.Add(Page.LoadControl("FacilityManagement.ascx")); lblPageTitle.Text="Facility"; break;


            case "fac_list": contentHolder.Controls.Add(Page.LoadControl("FacilityList.ascx"));lblPageTitle.Text="All facilities" ; break;
            case "fac_place": contentHolder.Controls.Add(Page.LoadControl("SupportedFacManagement.ascx")); lblPageTitle.Text = "Facility between places"; break;

            case "fac_type": contentHolder.Controls.Add(Page.LoadControl("FacilityTypeManagement.ascx")); lblPageTitle.Text="Facility type"; break;
            case "fac_type_list": contentHolder.Controls.Add(Page.LoadControl("FacilityTypeList.ascx")); lblPageTitle.Text = "All facility types"; break;

            case "article": contentHolder.Controls.Add(Page.LoadControl("ArticleManagement.ascx"));lblPageTitle.Text="Artilce" ; break;


            case "article_list": contentHolder.Controls.Add(Page.LoadControl("ArticleList.ascx"));lblPageTitle.Text="All articles" ; break;

            case "person": contentHolder.Controls.Add(Page.LoadControl("PersonManagement.ascx")); lblPageTitle.Text = "Person"; break;
           
            case "user": contentHolder.Controls.Add(LoadControl("UserManagement.ascx")); lblPageTitle.Text = "Account"; break;
            case "person_list": contentHolder.Controls.Add(LoadControl("PersonList.ascx")); lblPageTitle.Text = "Person list"; break;
            case "user_list": contentHolder.Controls.Add(LoadControl("UserList.ascx")); lblPageTitle.Text = "Accounts"; break;
            case "fb": contentHolder.Controls.Add(LoadControl("FeedbackDetails.ascx")); lblPageTitle.Text = "Feedback details"; break;
            case "fbs": contentHolder.Controls.Add(LoadControl("FeedbackList.ascx")); lblPageTitle.Text = "Feedbacks"; break;
            default: contentHolder.Controls.Add(LoadControl("Home.ascx")); lblPageTitle.Text="Home"; break;
                
        }
    }
    public void ShowFunctions()
    {
        try
        {
            User user = Session["user"] as User;
            if (user == null) Response.Redirect("~/pages/Default.aspx");
            lblUser.Text = ", " + user.UserName;
            if (user.Role <= 0 || user.Role >= 10)
            {
                pnlAdminTask.Visible = false;
            }
            else if (user.Role == 3)
            {
                lnkAddFacType.Visible = false;
                lnkAddSpotCate.Visible = false;
                lnkFacTypeList.Visible = false;               
                lnkSpotCateList.Visible = false;            
                lnkPlaceCate.Visible = false;
                pnlUser.Visible = false;
            }
        }
        catch (Exception ex)
        {
            lblMessage.Visible = true;
            lblMessage.CssClass = "message_box";
            lblMessage.Text = "Error. You do not have permission to view this page";
        }
    }

    protected void lnkAddPerson_Click(object sender, EventArgs e)
    {

    }
}
